﻿using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using UnityEditor;
using UnityEngine;

namespace BearUtil
{
    /// <summary>
    /// 语言类型
    /// </summary>
    public enum Localization
    {
        en = 3,
        cn = 4,
        tc = 5
    }

    /// <summary>
    /// 全局对话设置，向下继承
    /// </summary>
    public class StoriesSetting : GlobalConfig<StoriesSetting>, ICustomSetting
    {
        [BoxGroup("全局属性"), HideLabel]
        public BasicProperty basic;

        /// <summary>
        /// 全局设置，需求组件
        /// </summary>
        [BoxGroup("需求组件"), HideLabel]
        public StoriesProperty property;
        
        public string AddName 
        {
            get {  return "新增"; }
            set { }
        }

        public string RemoveName
        {
            get {  return "删除"; }
            set { }
        }

        public StoriesSetting()
        {
            if (basic == null)
                basic = new BasicProperty();
        }

        /// <summary>
        /// Add new StoryGraph
        /// </summary>
        public void Add(OdinMenuEditorWindow window)
        {
            // Create new Story in path 
            RightClickMenuItemsCreator.ShowDialog<StoryGraph>("Assets/StoryEditor/Graph/Data/", (obj) =>
            {
                // obj.titleName = obj.name;
                window.TrySelectMenuItemWithObject(obj);
            });
            AssetDatabase.Refresh();
        }
        
        /// <summary>
        ///  Remove Story Data
        /// </summary>
        public void Remove(OdinMenuItem selected)
        {
            // delete data 
            if (selected == null)
            {
                Debug.LogWarning("未找到删除对象");
                return;
            }

            (selected.Value as StoryGraph).DeleteSelf();
        }

        [Button("生成 Dialog Excel", ButtonSizes.Large)]
        public void OutputExce()
        {
            ExcelDataGenerator.GenerateStoryData();
        }
    
    }

}
